package security.core.filter;

import java.io.IOException;

import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

import org.springframework.web.filter.GenericFilterBean;

import security.debug.RBACLogger;

public class SessionContextFilter extends GenericFilterBean {
	private String loginPage;

	@Override
	public void doFilter(ServletRequest request, ServletResponse response,
			FilterChain chain) throws IOException, ServletException {
		// TODO Auto-generated method stub
		if (RBACLogger.debug()) {
			RBACLogger.log("SessionContextFilter#doFilter is called!");
		}
//		HttpServletRequest httpRequest = (HttpServletRequest) request;
//		HttpSession session = httpRequest.getSession();
//		if (session.getAttribute("RBAC_USER_DETAIL") != null) {
//			//UserDetail user = (UserDetail) session.getAttribute("RBAC_USER_DETAIL");
//			chain.doFilter(request, response);
//		} else {
//			((HttpServletResponse)response).sendRedirect(loginPage);
//		}
		chain.doFilter(request, response);
	}

	public void setLoginPage(String loginPage) {
		this.loginPage = loginPage;
	}

}
